﻿using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Validation;
using System.Linq;
using Agile.Models;

namespace Agile.Domain
{
    public partial class EfContent : DbContext
    {
        public EfContent() : base("Data Source=127.0.0.1;Database=HRIS;User ID=sa;Password=123456;MultipleActiveResultSets=true;")
        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //表名不用复数形式
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            base.OnModelCreating(modelBuilder);
        }
        //Common
        public DbSet<Application> Application { get; set; }
        public DbSet<DictData> DictData { get; set; }
        public DbSet<Relevance> Relevance { get; set; }
        public DbSet<Setting> Setting { get; set; }
        public DbSet<UploadFile> UploadFile { get; set; }
        public DbSet<Friendlink> Friendlink { get; set; }

        //Flow
        public DbSet<FlowInstance> FlowInstance { get; set; }
        public DbSet<FlowInstanceOperationHistory> FlowInstanceOperationHistory { get; set; }
        public DbSet<FlowInstanceTransitionHistory> FlowInstanceTransitionHistory { get; set; }
        public DbSet<FlowScheme> FlowScheme { get; set; }
        public DbSet<Form> Form { get; set; }
        public DbSet<FrmLeaveReq> FrmLeaveReq { get; set; }
        //Personnel
        public DbSet<EducationResume> EducationResume { get; set; }
        public DbSet<OrgTransfer> OrgTransfer { get; set; }
        public DbSet<ProjectResume> ProjectResume { get; set; }
        public DbSet<Socialrelations> Socialrelations { get; set; }
        public DbSet<TeacherInfo> TeacherInfo { get; set; }
        public DbSet<TrainResume> TrainResume { get; set; }
        public DbSet<WorkResume> WorkResume { get; set; }
        //Rbac
        public DbSet<Resource> Resource { get; set; }
        public DbSet<Menu> Menu { get; set; }
        public DbSet<MenuElement> MenuElement { get; set; }
        public DbSet<MenuFast> MenuFast { get; set; }
        public DbSet<Org> Org { get; set; }
        public DbSet<Role> Role { get; set; }
        public DbSet<User> User { get; set; }
        //工资公式
        public DbSet<Formulary> Formulary { get; set; }
        public DbSet<Salary> Salary { get; set; }
        public DbSet<SalaryItem> SalaryItem { get; set; }
        public DbSet<SalaryItemType> SalaryItemType { get; set; }


        public int ExecuteSql(string sql, params object[] parameters)
        {
            return this.Database.ExecuteSqlCommand(sql, parameters);
        }
    }
    /// <summary>
    /// 数据库初始化操作类
    /// </summary>
    internal sealed class EfContentInit
    {
        static string _tenantId = "73e9f875-c5f4-458a-95b7-dd06c144d370";
        internal static void Initialize()
        {
            try
            {
                Console.WriteLine("生成数据库开始:");
                Database.SetInitializer(new DropCreateDatabaseIfModelChanges<EfContent>());
                Database.SetInitializer(new SampleData());
                using (var db = new EfContent())
                {
                    Console.WriteLine("正在生成数据库..................");
                    db.Database.Initialize(false);
                }
                InitData();
                Console.WriteLine("生成数据库结束");
            }
            catch (Exception ex)
            {
                try
                {
                    Console.WriteLine("生成数据库错误:");
                    Console.WriteLine(GetInnerException(ex));
                }
                catch (Exception)
                {

                }
            }
        }
        internal static string GetInnerException(Exception ex)
        {
            if (ex.InnerException != null)
            {
                if (ex.InnerException is DbEntityValidationException)
                {
                    LogDbEntityValidationException((DbEntityValidationException)ex.InnerException);
                }
                return GetInnerException(ex.InnerException);
            }
            return ex.Message;
        }
        internal static void LogDbEntityValidationException(DbEntityValidationException exception)
        {
            Console.WriteLine(exception.Message);
            foreach (var ve in exception.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors))
            {
                Console.WriteLine(" - " + ve.PropertyName + ": " + ve.ErrorMessage);
            }
        }
        internal class SampleData : CreateDatabaseIfNotExists<EfContent>
        {
            protected override void Seed(EfContent context)
            {
                RabcTestData(context);
                context.SaveChanges();
            }
            public void RabcTestData(EfContent context)
            {
                context.Application.Add(new Application { ID = _tenantId, Name = "ASP.NET Core敏捷开发框架", AppSecret = "agile", Description = "最好用的.NET权限工作流框架" });

                string dict_rootid = Guid.NewGuid().ToString();
                string dict_rootid1 = Guid.NewGuid().ToString();
                string dict_rootid2 = Guid.NewGuid().ToString();
                string dict_rootid3 = Guid.NewGuid().ToString();
                context.DictData.Add(new DictData { ID = dict_rootid, ParentID = Guid.Empty.ToString(), Name = "个人基本信息", ParentName = "根节点" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "婚姻状况", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "健康状况", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "从业状况", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "政治面貌", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "学历代码", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "政协委员", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "院士代码", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "户口类别", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid, Name = "宗教信仰", ParentName = "个人基本信息" });
                context.DictData.Add(new DictData { ID = dict_rootid1, ParentID = Guid.Empty.ToString(), Name = "出入境", ParentName = "根节点" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid1, Name = "护照种类", ParentName = "出入境" });
                context.DictData.Add(new DictData { ID = Guid.NewGuid().ToString(), ParentID = dict_rootid1, Name = "签证种类", ParentName = "出入境" });

                string org_rootid = Guid.NewGuid().ToString();
                string org_rootid1 = Guid.NewGuid().ToString();
                string org_rootid2 = Guid.NewGuid().ToString();
                context.Org.Add(new Org { ID = org_rootid, ParentID = Guid.Empty.ToString(), Name = "集团总部", TenantId = _tenantId, ParentName = "根节点", IsLeaf = false });
                context.Org.Add(new Org { ID = org_rootid1, ParentID = org_rootid, Name = "子公司", TenantId = _tenantId, ParentName = "集团总部", IsLeaf = false, IsAutoExpand = true });
                context.Org.Add(new Org { ID = org_rootid2, ParentID = org_rootid1, Name = "研发组", TenantId = _tenantId, ParentName = "子公司", IsLeaf = true, IsAutoExpand = true });
                context.Org.Add(new Org { ID = Guid.NewGuid().ToString(), ParentID = Guid.Empty.ToString(), Name = "阿里巴巴", TenantId = _tenantId, ParentName = "根节点", IsLeaf = false });

                #region Menu
                string Menu_rootid2 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid2, ParentID = Guid.Empty.ToString(), Name = "基础设施", Url = "/common", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 0 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "资源管理", ParentName = "基础设施", Url = "/rbac/Resources/index", TenantId = _tenantId, Code = "Resource", IsSys = false, IsLeaf = true, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "数据字典", ParentName = "基础设施", Url = "/common/DictData/index", TenantId = _tenantId, Code = "DictData", IsSys = false, IsLeaf = true, OrderBy = 2 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "模块管理", ParentName = "基础设施", Url = "/rbac/Menu/index", TenantId = _tenantId, Code = "Menu", IsSys = true, IsLeaf = true, OrderBy = 3 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "角色管理", ParentName = "基础设施", Url = "/rbac/Role/index", TenantId = _tenantId, Code = "Role", IsSys = true, IsLeaf = true, OrderBy = 4 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "用户管理", ParentName = "基础设施", Url = "/rbac/User/index", TenantId = _tenantId, Code = "User", IsSys = true, IsLeaf = true, OrderBy = 5 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "部门管理", ParentName = "基础设施", Url = "/rbac/Org/index", TenantId = _tenantId, Code = "Org", IsSys = true, IsLeaf = true, OrderBy = 6 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid2, Name = "计划任务", ParentName = "基础设施", Url = "/BackgroundTask/index", TenantId = _tenantId, Code = "BackgroundTask", IsSys = true, IsLeaf = true, OrderBy = 7 });

                string Menu_rootid1 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid1, ParentID = Guid.Empty.ToString(), Name = "流程中心", Url = "/flow", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid1, Name = "流程设计", ParentName = "流程中心", Url = "/flow/flowSchemes/index", TenantId = _tenantId, Code = "FlowScheme", IsSys = true, IsLeaf = true, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid1, Name = "表单设计", ParentName = "流程中心", Url = "/flow/forms/index", TenantId = _tenantId, Code = "Form", IsSys = true, IsLeaf = true, OrderBy = 2 });
                string Menu_rootid3 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid3, ParentID = Guid.Empty.ToString(), Name = "人员管理", Url = "/personnel", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 2 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "部门调动", Url = "/personnel/OrgTransfer/index", TenantId = _tenantId, Code = "OrgTransfer", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "人员信息", Url = "/personnel/Roster/index", TenantId = _tenantId, Code = "Roster", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 2 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "教师详细", Url = "/personnel/TeacherInfo/index", TenantId = _tenantId, Code = "TeacherInfo", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 3 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "家庭成员", Url = "/personnel/Socialrelations/index", TenantId = _tenantId, Code = "Socialrelations", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 4 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "工作经验", Url = "/personnel/WorkResume/index", TenantId = _tenantId, Code = "WorkResume", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 5 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "教育经历", Url = "/personnel/EducationResume/index", TenantId = _tenantId, Code = "EducationResume", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 6 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "项目经验", Url = "/personnel/ProjectResume/index", TenantId = _tenantId, Code = "ProjectResume", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 7 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid3, Name = "培训经历", Url = "/personnel/TrainResume/index", TenantId = _tenantId, Code = "TrainResume", IsSys = true, ParentName = "人员管理", IsLeaf = false, OrderBy = 8 });
                string Menu_rootid4 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid4, ParentID = Guid.Empty.ToString(), Name = "考勤管理", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 3 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid4, Name = "排班管理", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "考勤管理", IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid4, Name = "班次管理", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "考勤管理", IsLeaf = false, OrderBy = 2 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid4, Name = "考勤设定", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "考勤管理", IsLeaf = false, OrderBy = 3 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid4, Name = "假期日历", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "考勤管理", IsLeaf = false, OrderBy = 4 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid4, Name = "考勤权限", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "考勤管理", IsLeaf = false, OrderBy = 5 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid4, Name = "考勤查询", Url = "/attendance", TenantId = _tenantId, IsSys = true, ParentName = "考勤管理", IsLeaf = false, OrderBy = 6 });
                string Menu_rootid5 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid5, ParentID = Guid.Empty.ToString(), Name = "薪酬福利", Url = "/paywelfare", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 4 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid5, Name = "个税设定", Url = "/paywelfare", TenantId = _tenantId, IsSys = true, ParentName = "薪酬福利", IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid5, Name = "社保设定", Url = "/paywelfare", TenantId = _tenantId, IsSys = true, ParentName = "薪酬福利", IsLeaf = false, OrderBy = 2 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid5, Name = "薪酬设定", Url = "/paywelfare", TenantId = _tenantId, IsSys = true, ParentName = "薪酬福利", IsLeaf = false, OrderBy = 3 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid5, Name = "薪资处理", Url = "/paywelfare", TenantId = _tenantId, IsSys = true, ParentName = "薪酬福利", IsLeaf = false, OrderBy = 4 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid5, Name = "薪资结果导入", Url = "/paywelfare", TenantId = _tenantId, IsSys = true, ParentName = "薪酬福利", IsLeaf = false, OrderBy = 5 });
                string Menu_rootid7 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid7, ParentID = Guid.Empty.ToString(), Name = "招聘管理", Url = "/recruit", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 5 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid7, Name = "招聘计划", Url = "/recruit", TenantId = _tenantId, IsSys = true, ParentName = "招聘管理", IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid7, Name = "简历筛选", Url = "/recruit", TenantId = _tenantId, IsSys = true, ParentName = "招聘管理", IsLeaf = false, OrderBy = 2 });
                string Menu_rootid6 = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid6, ParentID = Guid.Empty.ToString(), Name = "培训管理", Url = "/train", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 6 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid6, Name = "培训计划", Url = "/train", TenantId = _tenantId, IsSys = true, ParentName = "培训管理", IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid6, Name = "培训结果", Url = "/train", TenantId = _tenantId, IsSys = true, ParentName = "培训管理", IsLeaf = false, OrderBy = 2 });
                string Menu_rootid = Guid.NewGuid().ToString();
                context.Menu.Add(new Menu { ID = Menu_rootid, ParentID = Guid.Empty.ToString(), Name = "代办事项", Url = "/flow", TenantId = _tenantId, IsSys = true, ParentName = "根节点", IsLeaf = false, OrderBy = 20 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid, Name = "已处理流程", ParentName = "代办事项", Url = "/flow/flowinstances/disposed", TenantId = _tenantId, Code = "FlowInstanceDisposed", IsSys = true, IsLeaf = false, OrderBy = 0 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid, Name = "待处理流程", ParentName = "代办事项", Url = "/flow/flowinstances/wait", TenantId = _tenantId, Code = "FlowInstanceWait", IsSys = true, IsLeaf = false, OrderBy = 1 });
                context.Menu.Add(new Menu { ID = Guid.NewGuid().ToString(), ParentID = Menu_rootid, Name = "我的流程", ParentName = "代办事项", Url = "/flow/flowInstances/index", TenantId = _tenantId, Code = "FlowInstance", IsSys = true, IsLeaf = false, OrderBy = 2 });
                #endregion

                context.Form.Add(new Form { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, Name = "自定义开发的复杂表单", FrmType = 0, WebId = "FrmLeaveReq", Content = "", ContentParse = "", ContentData = "", Fields = 0, Disabled = 1, Description = "自定义开发的复杂表单，当前只对企业版开放" });
                context.Form.Add(new Form { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, Name = "简单的动态表单--领料单", FrmType = 0, Content = "", ContentParse = "", ContentData = "", Fields = 0, Disabled = 1, Description = "简单的动态表单，适用于无需编程，快速添加" });
                context.Form.Add(new Form { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, Name = "MVC添加的请假条", FrmType = 0, Content = "", ContentParse = "", ContentData = "", Fields = 0, Disabled = 1, Description = "这个表单是用开源MVC添加的，和企业版的效果一致" });

                context.FlowScheme.Add(new FlowScheme { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, SchemeCode = "1564314361470", SchemeName = "一个普通的请假流程", Description = "里面有所有人都可审批、指定用户可审批", SortCode = 1 });
                context.FlowScheme.Add(new FlowScheme { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, SchemeCode = "1564314509135", SchemeName = "指定角色的审批流程", Description = "", SortCode = 2 });
                context.FlowScheme.Add(new FlowScheme { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, SchemeCode = "1564314688386", SchemeName = "复杂表单的流程", Description = "这是企业版添加的复杂表单流程，基于开发的表单页面，可以实现复杂的表单交互功能，如上传等" });
                context.FlowScheme.Add(new FlowScheme { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, SchemeCode = "1564314688386", SchemeName = "带条件分支领料模板", Description = "可以在分支线上设定分支条件" });
                context.FlowScheme.Add(new FlowScheme { ID = Guid.NewGuid().ToString(), TenantId = _tenantId, SchemeCode = "1564320423976", SchemeName = "带会签功能的流程", Description = "需要多人审批通过，或至少有一个审批通过的情况" });

                context.Resource.Add(new Resource { ID = "OPENAUTH_DELETEACCOUNT", TenantId = _tenantId, Name = "注销账号", Description = "注销账号的权限" });
                context.Resource.Add(new Resource { ID = "OPENAUTH_LOGIN", TenantId = _tenantId, Name = "登陆", Description = "登陆的权限" });
                context.Resource.Add(new Resource { ID = "OPENAUTH_MODIFYACCOUNT", TenantId = _tenantId, Name = "修改账号", Description = "修改账号的权限" });

                context.Role.Add(new Role { ID = Guid.NewGuid().ToString(), Name = "管理员", Status = 0, TenantId = _tenantId, TypeId = "0", OrderBy = 1 });
                context.Role.Add(new Role { ID = Guid.NewGuid().ToString(), Name = "人事专员", Status = 0, TenantId = _tenantId, TypeId = "0", OrderBy = 2 });
                context.Role.Add(new Role { ID = Guid.NewGuid().ToString(), Name = "考勤专员", Status = 0, TenantId = _tenantId, TypeId = "0", OrderBy = 3 });
                context.Role.Add(new Role { ID = Guid.NewGuid().ToString(), Name = "薪酬专员", Status = 0, TenantId = _tenantId, TypeId = "0", OrderBy = 4 });
                context.Role.Add(new Role { ID = Guid.NewGuid().ToString(), Name = "福利专员", Status = 0, TenantId = _tenantId, TypeId = "0", OrderBy = 5 });

                context.User.Add(new User { ID = "admin", Account = "admin", Name = "admin", Password = "admin", BizCode = "", Sex = 1, TenantId = _tenantId, });
                for (int i = 0; i < 20; i++)
                {
                    string user_id = Guid.NewGuid().ToString();
                    context.User.Add(new User { ID = user_id, Account = "luomingui" + i, Name = "luomingui" + i, Password = "luomingui", BizCode = "", Sex = 1, TenantId = _tenantId, OrderBy = i });
                    context.Relevance.Add(new Relevance { ID = Guid.NewGuid().ToString(), Key = "UserOrg", FirstId = user_id, SecondId = org_rootid2, TenantId = _tenantId });
                }

                for (int i = 0; i < 20; i++)
                {
                    context.TrainResume.Add(new TrainResume { ID = Guid.NewGuid().ToString(), BeginDate = DateTime.Now, EndhDate = DateTime.Now.AddDays(i), Organization = "江西应用", Course = "计算机科学" + i, Description = "计算机应用基础、计算机组装与维护、计算机局域网络的建设与管理、网络工程、操作系统、服务器、数据库的开发与应用、网站建设与网页设计、C/C++语言、Visual Basic语言、平面设计、3D图形设计、多媒体设计、专业英语。", OrderBy = i });
                }
            }
        }
        internal static void InitData()
        {
            Console.WriteLine("生成数据库模块功能:");
            using (var context = new EfContent())
            {
                Console.WriteLine("生成数据库模块功能..............................");
                var list = context.Menu.ToList();
                foreach (Menu item in list)
                {
                    string name = item.Name.Replace("管理", "");
                    if (item.Name == "我的流程")
                    {
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnAdd", Name = "新的申请", Remark = "添加" + name, Icon = "layui-icon-add-1", Class = "layui-btn-normal", Script = "add()", OrderBy = 10 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnDel", Name = "删除", Remark = "删除" + name, Icon = "layui-icon-delete", Class = "layui-btn-danger", Script = "del()", OrderBy = 9 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnDetail", Name = "进度详情", Icon = "layui-icon-search", Class = "layui-btn-normal", Script = "", OrderBy = 8 });
                    }
                    else if (item.Name == "待处理流程")
                    {
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnVerification", Name = "处理", Remark = "处理" + name, Icon = "layui-icon-triangle-r", Class = "layui-btn-normal", Script = "", OrderBy = 10 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnDetail", Name = "进度详情", Remark = "进度详情" + name, Icon = "layui-icon-search", Class = "layui-btn-danger", Script = "", OrderBy = 9 });
                    }
                    else if (item.Name == "已处理流程")
                    {
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnDetail", Name = "查看详情", Remark = "查看详情" + name, Icon = "layui-icon-search", Class = "layui-btn-normal", Script = "", OrderBy = 10 });
                    }
                    else
                    {

                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "search", Name = "搜索", Remark = "搜索" + name, Icon = "layui-icon-search", Class = "layui-btn-normal", Script = "search()", OrderBy = 12 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnRefresh", Name = "刷新", Remark = "刷新" + name, Icon = "layui-icon-refresh", Class = "layui-btn", Script = "Import()", OrderBy = 11 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnAdd", Name = "添加", Remark = "添加" + name, Icon = "layui-icon-add-1", Class = "layui-btn-normal", Script = "add()", OrderBy = 10 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnEdit", Name = "编辑", Remark = "编辑" + name, Icon = "layui-icon-edit", Class = "layui-btn-warm", Script = "edit()", OrderBy = 9 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnDel", Name = "删除", Remark = "删除" + name, Icon = "layui-icon-delete", Class = "layui-btn-danger", Script = "del()", OrderBy = 8 });
                        context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnImport", Name = "导入", Remark = "导入" + name, Icon = "layui-icon-upload-drag", Class = "layui-btn", Script = "Import()", OrderBy = 7 });


                        if (item.Name == "模块管理")
                        {
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnAddMenu", Name = "添加菜单", Icon = "layui-icon-add-1", Class = "layui-btn-normal", Script = "assignButton()", OrderBy = 6 });
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnEditMenu", Name = "编辑菜单", Icon = "layui-icon-edit", Class = "layui-btn-normal", Script = "", OrderBy = 5 });
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnDelMenu", Name = "删除菜单", Icon = "layui-icon-delete", Class = "layui-btn-danger", Script = "", OrderBy = 4 });
                        }
                        else if (item.Name == "用户管理")
                        {
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnAccessRole", Name = "为用户分配角色", Remark = "为用户分配角色", Icon = "layui-icon-search", Class = "layui-btn-normal", Script = "openUserRoleAccess(this)", OrderBy = 6 });
                        }
                        else if (item.Name == "流程设计")
                        {
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnPreview", Name = "预览", Remark = "预览" + name, Icon = "layui-icon-cellphone", Class = "layui-btn-normal", Script = "", OrderBy = 6 });
                        }
                        else if (item.Name == "角色管理")
                        {
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnAccessMenu", Name = "为角色分配模块", Remark = "为角色分配模块" + name, Icon = "layui-icon-search", Class = "layui-btn-normal", Script = "assignRoleMenu(this)", OrderBy = 6 });
                            context.MenuElement.Add(new MenuElement { ID = Guid.NewGuid().ToString(), MenuId = item.ID, DomId = "btnAssignReource", Name = "为角色分配资源", Remark = "为角色分配资源" + name, Icon = "layui-icon-search", Class = "layui-btn-normal", Script = "openRoleReourceAccess(this)", OrderBy = 5 });
                        }
                    }
                    context.SaveChanges();
                }
            }
            Console.WriteLine("生成数据库模块功能完成");
        }
    }

    internal class Configuration : DbMigrationsConfiguration<EfContent>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }
        protected override void Seed(EfContent context)
        {
         
        }
    }
}
